package com.itheima.manager;

import com.itheima.domain.OrderReturnReason;
import com.itheima.service.OmsOrderReturnReasonService;
import com.itheima.util.Result;
import com.itheima.vo.PageBeanVo;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Component;

@Component
public class OmsOrderReturnReasonManager {
    @DubboReference
    OmsOrderReturnReasonService omsOrderReturnReasonService;

    //分页查询退货原因
    public Result list(Integer pageNum, Integer pageSize) {
        //调用service完成pageBeanVo
        PageBeanVo pageBeanVo = omsOrderReturnReasonService.list(pageNum,pageSize);

        //返回结果
        return new Result(true,200,"操作成功",pageBeanVo);
    }


    //获取单个退货原因详情信息
    public Result findById(Integer id) {
        //调用service获取单个退货详情对象
        OrderReturnReason omsOrderReturnReason = omsOrderReturnReasonService.findById(id);
        //返回结果
        return  new Result(true,200,"操作成功",omsOrderReturnReason);
    }

    //批量删除退货原因
    public Result delete(Integer[] ids) {
        //调用service完成删除操作
      int count =   omsOrderReturnReasonService.delete(ids);
        if (count==0){
            return new Result(false,500,"操作失败",count);
        }

        return new Result(true,200,"操作成功",count);
    }

    //添加退货原因
    public Result add(OrderReturnReason omsOrderReturnReason) {
    //调用service完程添加操作
        int count = omsOrderReturnReasonService.add(omsOrderReturnReason);
        if (count==0){
            return new Result(false,500,"添加失败",count);
        }

        return new Result(true,200,"添加成功",count);

    }


    //修改退货原因启用状态
    public Result updateStatus(Integer ids, Integer status) {
   //1.调用service完程更新状态操作
        int count = omsOrderReturnReasonService.updateStatus(ids,status);

        //2.返回结果
        return new Result(true,200,"操作成功",count);

    }


    //修改退货原因
    public Result updateById(Integer id, OrderReturnReason omsOrderReturnReason) {
    //调用service完成修改操作
        int count = omsOrderReturnReasonService.updateById(id,omsOrderReturnReason);
        return new Result(true,200,"操作成功",count);
    }
}
